import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import { getProfileAPI } from '@/api/user'
Vue.use(Vuex)

export default new Vuex.Store({
  state: () => {
    return {
      profile: {}
    }
  },
  mutations: {
    setProfile(state, profile) {
      state.profile = profile
    }
  },
  actions: {
    async getProfile(ctx) {
      const res = await getProfileAPI()
      ctx.commit('setProfile', res.data)
      return res.data.permission
    }
  },
  modules: {
    user
  }
})
